import Vue from 'vue'
import App from './App.vue'
import router from './router'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss'

// 指令
import directive from './directive'

// 全局注册组件
import globalComponents from "./components/index"

// 监控组件,启动监控服务端:切换到根目录server文件夹,npm run start
import WebMonitor from './components/WebMonitor/index';
import recordScreen from './components/WebMonitor/recordscreen';

// 注册页面录屏插件
WebMonitor.use(recordScreen);

Vue.use(WebMonitor, {
  dsn: 'http://localhost:8083/api/monitor/reportData',
  apikey: '项目1',
  silentRecordScreen: true,
  userId: '999',
  handleHttpStatus(res) {
    const { url, response } = res;
    const data = typeof response === 'string' ? JSON.parse(response) : response;
    const { code } = data
    // code为200，接口正常
    if (url.includes('/getErrorList')) {
      return code === 200 ? true : false;
    } else {
      return code === 200 ? true : false;
    }
  },
});

Vue
  .use(ElementUI)
  .use(directive)
  .use(globalComponents)

new Vue({
  el: '#app',
  router,
  render: h => h(App)
})
